Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util: improve isInsideNodeModules #52147

Merged
merged 1 commit into from May 5, 2024

Conversation

Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Mar 18, 2024

Improve isInsideNodeModules by avoiding a Regex
kNodeModulesRE is using a non-capturing group

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Mar 18, 2024
lib/internal/util.js Outdated Show resolved Hide resolved
lib/internal/util.js Outdated Show resolved Hide resolved
lib/internal/util.js Outdated Show resolved Hide resolved
lib/internal/util.js Outdated Show resolved Hide resolved
@Uzlopak Uzlopak force-pushed the util-isInsideNodeModules branch 2 times, most recently from d08b72a to 0778337 Compare March 20, 2024 22:00
@aduh95
Copy link
Contributor

aduh95 commented Mar 20, 2024

kNodeModulesRE is using a non-capturing group

Just curious, did you do that for performance reasons, or is that a neutral change to make the regex more intention-revealing?

@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Mar 20, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 20, 2024
@nodejs-github-bot
Copy link
Collaborator

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Mar 20, 2024

I just saw that the capturing group is not used and the captured string can be very long. So i had performance in mind, but i didnt wanted to claim a (significant?) performance gain, which i probably cant prove.

@aduh95
Copy link
Contributor

aduh95 commented Mar 20, 2024

Looks like this a breaking the following tests:

  • parallel.test-buffer-constructor-outside-node-modules
  • parallel.test-buffer-constructor-node-modules-paths

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Mar 20, 2024

I will have a look at it in few hours ;)

@Uzlopak Uzlopak closed this Mar 21, 2024
@Uzlopak Uzlopak reopened this Mar 21, 2024
@Uzlopak
Copy link
Contributor Author

Uzlopak commented Mar 21, 2024

@aduh95

Should be fixed now.

@aduh95 aduh95 added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 21, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 21, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Apr 15, 2024

@nodejs/node-core-utils

can this be merged?

if (RegExpPrototypeExec(/^\/|\\/, filename) === null)
if (
filename[0] !== '/' &&
StringPrototypeIncludes(filename, '\\') === false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only applies to Windows right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR is already old but afaik it was effecting linux too

@BridgeAR BridgeAR added the request-ci Add this label to start a Jenkins CI on a PR. label May 4, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 4, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label May 5, 2024
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels May 5, 2024
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/52147
✔  Done loading data for nodejs/node/pull/52147
----------------------------------- PR info ------------------------------------
Title      util: improve isInsideNodeModules (#52147)
Author     Aras Abbasi  (@Uzlopak)
Branch     Uzlopak:util-isInsideNodeModules -> nodejs:main
Labels     util, author ready, needs-ci
Commits    1
 - util: improve isInsideNodeModules
Committers 1
 - uzlopak 
PR-URL: https://github.com/nodejs/node/pull/52147
Reviewed-By: Antoine du Hamel 
Reviewed-By: Ruben Bridgewater 
Reviewed-By: Luigi Pinca 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/52147
Reviewed-By: Antoine du Hamel 
Reviewed-By: Ruben Bridgewater 
Reviewed-By: Luigi Pinca 
--------------------------------------------------------------------------------
   ℹ  This PR was created on Mon, 18 Mar 2024 20:58:36 GMT
   ✔  Approvals: 3
   ✔  - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/52147#pullrequestreview-1950310069
   ✔  - Ruben Bridgewater (@BridgeAR) (TSC): https://github.com/nodejs/node/pull/52147#pullrequestreview-1951180547
   ✔  - Luigi Pinca (@lpinca): https://github.com/nodejs/node/pull/52147#pullrequestreview-1953430893
   ✘  Last GitHub CI failed
   ℹ  Last Full PR CI on 2024-05-05T08:45:43Z: https://ci.nodejs.org/job/node-test-pull-request/58945/
- Querying data for job/node-test-pull-request/58945/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/8957320660

PR-URL: nodejs#52147
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@aduh95 aduh95 force-pushed the util-isInsideNodeModules branch from f02a1ba to b77f32b Compare May 5, 2024 09:56
@aduh95 aduh95 merged commit b77f32b into nodejs:main May 5, 2024
21 checks passed
@Uzlopak Uzlopak deleted the util-isInsideNodeModules branch May 5, 2024 10:13
Ch3nYuY pushed a commit to Ch3nYuY/node that referenced this pull request May 8, 2024
PR-URL: nodejs#52147
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
targos pushed a commit that referenced this pull request May 8, 2024
PR-URL: #52147
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-failed An error occurred while landing this pull request using GitHub Actions. needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants